//
//  DetailCell.m
//  YiXiu
//
//  Created by yixiu on 16/8/3.
//  Copyright © 2016年 zzz. All rights reserved.
//

#import "DetailCell.h"

@interface DetailCell ()

//头像url
@property(nonatomic, strong) UIImageView * u_headUrl;

//昵称
@property(nonatomic, strong) UILabel * u_name;


//帖子内容
@property(nonatomic, strong) UILabel * p_content;

//内容图片
@property(nonatomic, strong) UIImageView * pt_url;


@end

@implementation DetailCell

- (instancetype) init{
    
    if (self = [super init]) {
        
        
        [self addSubViews];
        
        
    }
    return self;
}


- (void)addSubViews{
    
    UIImageView * headImg = [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, 60 , 60)];
//    headImg.backgroundColor = [UIColor greenColor];
    headImg.layer.cornerRadius = 30;
    headImg.clipsToBounds = YES;
    [self addSubview:headImg];
    
    
    
    UILabel * nameL = [[UILabel alloc] initWithFrame:CGRectMake(70, 0, KScreenWidth - 20 - 60, 60)];
//    nameL.backgroundColor = [UIColor blueColor];
    [self addSubview:nameL];
    nameL.font = [UIFont systemFontOfSize:24];
    
    
    UILabel * contentL = [[UILabel alloc] initWithFrame:CGRectMake(10, 70, KScreenWidth - 20, 100)];
    contentL.numberOfLines = 0;
    contentL.backgroundColor = [UIColor greenColor];
    [self addSubview:contentL];
    contentL.font = [UIFont systemFontOfSize:18];

    
    UIImageView * imageV = [[UIImageView alloc] initWithFrame:CGRectMake(10, 180, KScreenWidth - 20, 200)];
    imageV.contentMode = UIViewContentModeScaleAspectFill;
    imageV.clipsToBounds = YES;
    imageV.backgroundColor = [UIColor yellowColor];
    [self addSubview:imageV];
    

    self.u_headUrl = headImg;
    self.u_name = nameL;
    self.p_content = contentL;
    self.pt_url = imageV;
    
}



- (void)setModel:(CommModelSize *)model{
    _model = model;
    
    self.u_name.text = model.model.u_name;
    self.p_content.text = model.model.p_content;
    
    [self.u_headUrl sd_setImageWithURL:[NSURL URLWithString:model.model.u_headUrl]];

    [self.pt_url.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    if (model.imageS.count == 1) {
        
        [self.pt_url sd_setImageWithURL:[NSURL URLWithString:model.model.pt_url]];
        
    }else{
        
        [model.imageS enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            
            UIImageView * imageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 200 * idx, KScreenWidth - 20, 190)];
            imageV.contentMode = UIViewContentModeScaleAspectFill;
            imageV.clipsToBounds = YES;
            [imageV sd_setImageWithURL:[NSURL URLWithString:obj]];
            [self.pt_url addSubview:imageV];
            
        }];
    }
    
    self.p_content.frame = model.p_content;
    self.pt_url.frame = model.pt_url;

}


@end
